package global

import (
	"fmt"
	"log"
	"os"

	"github.com/gin-gonic/gin"
)

// init 配置日志信息
func init() {
	if gin.Mode() == "release" {
		logFile, err := os.OpenFile(Config.LogFile, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0644)
		if err != nil {
			fmt.Println("open log file failed, err:", err)
			return
		}
		log.SetOutput(logFile)
	} else {
		log.SetOutput(os.Stdout)
		log.SetFlags(log.Lshortfile | log.Ltime | log.Ldate)
	}
}
